package com.yidu.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yidu.common.Tools;
import com.yidu.dao.ListenBackstageUserMapper;
import com.yidu.domain.ListenBackstageUser;
import com.yidu.service.ListenBackstageUserService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiuXiang
 * @since 2018-11-27
 */
@Service
public class ListenBackstageUserServiceImpl implements ListenBackstageUserService {
	
	@Resource
	private ListenBackstageUserMapper userMapper;
	/**
	 * 查询所有,分页
	 */
	@Override
	public PageInfo<ListenBackstageUser> findAll(Integer page, Integer pageSize, ListenBackstageUser userName) {
		PageHelper.startPage(page, pageSize);
        List<ListenBackstageUser> store = userMapper.findAll(userName);
        for (ListenBackstageUser listenBackstageUser : store) {
        	String timeStr = Tools.getTimeStr(listenBackstageUser.getOpenTime());
        	listenBackstageUser.setOpenStringTime(timeStr);
		}
        PageInfo<ListenBackstageUser> storePageInfo = new PageInfo<>(store);
        return storePageInfo;
	}

	@Override
	public int insertSelective(ListenBackstageUser user) {
		user.setBuId(Tools.getRandomString());
		return userMapper.insertSelective(user);
	}

	@Override
	public int updateByPrimaryKeySelective(ListenBackstageUser user) {
		return userMapper.updateByPrimaryKeySelective(user);
	}

	@Override
	public ListenBackstageUser selectByPrimaryKey(String buId) {
		return userMapper.selectByPrimaryKey(buId);
	}

	@Override
	public int deleteByPrimaryKey(String buId) {
		return userMapper.deleteByPrimaryKey(buId);
	}

	@Override
	public List<ListenBackstageUser> querAll() {
		return userMapper.querAll();
	}

	@Override
	public int disable(ListenBackstageUser user) {
		return userMapper.disable(user);
	}

	@Override
	public int enable(ListenBackstageUser user) {
		return userMapper.enable(user);
	}

	@Override
	public ListenBackstageUser selectNamePswd(String buName, String buPwd) {
		return userMapper.selectNamePswd(buName,buPwd);
	}

	@Override
	public ListenBackstageUser selectByName(String buName) {
		
		return userMapper.selectByBuName(buName);
	}
}
